import { createRouter, createWebHistory } from 'vue-router'
import Home from './views/Home.vue';
import Login from './views/Login.vue'
import NotFound from './views/NotFound.vue'
import Dashboard from './views/Dashboard.vue';
import Sub2 from './views/Sub2.vue';
import Sub1 from './views/Sub1.vue';

const routes = [
    {
        path: '/home',
        name: 'Home',
        component: Home,
        // children: [
        //     {
        //         path: 'child1',
        //         name: 'Child1',
        //         component: Child1
        //     },
        //     {
        //         path: 'child2',
        //         name: 'Child2',
        //         component: Child2
        //     }
        // ]
    },
    {
        path: '/',
        name: 'default',
        redirect: 'login'
    },
    {
        path: '/login',
        name: 'Login',
        component: Login,
        children: [
            {
                path: 'sub1',
                name: 'sub1',
                component: Sub1
            },
            {
                path: 'sub2',
                name: 'sub2',
                component: Sub2
            }
        ]
    },
    {
        path: '/:pathMatch(.*)*', // 匹配所有未定义的路由
        name: 'NotFound',
        component: NotFound,
      },
];

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL || '/'),
    // history: createWebHashHistory(),
    routes
});

export default router;